/*
 * Copyright 2013 NJUT  qixiaobo. All rights reserved.
 */
package com.fujitsu.nanjing.tieba.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fujitsu.nanjing.tieba.base.BaseService;
import com.fujitsu.nanjing.tieba.ibator.CoreArchiveTopic;
import com.fujitsu.nanjing.tieba.ibator.CoreArchiveTopicCriteria;
import com.fujitsu.nanjing.tieba.model.ArchiveTopic;

/**
 * ArchiveTopicService.java
 * 
 * @author Administrator
 */
@Transactional
@Service
public class ArchiveTopicService
		extends
			BaseService<CoreArchiveTopic, CoreArchiveTopicCriteria> {
	@Resource
	private ArchiveTopic arachiveTopic;
	@Override
	public CoreArchiveTopic findById(String id) {
		CoreArchiveTopicCriteria example = new CoreArchiveTopicCriteria();
		example.createCriteria().andTopicidEqualTo(Integer.parseInt(id));
		List<CoreArchiveTopic> topics = arachiveTopic
				.selectByExampleWithoutBLOBs(example);
		if (topics != null && topics.size() > 0) {
			return topics.get(0);
		}
		return null;
	}
	@Override
	public CoreArchiveTopic insert(CoreArchiveTopic t) {
		arachiveTopic.insertSelective(t);
		return t;
	}

	@Override
	public void update(CoreArchiveTopic t) {
		CoreArchiveTopicCriteria example = new CoreArchiveTopicCriteria();
		example.createCriteria().andTopicidEqualTo(t.getTopicid());
		arachiveTopic.updateByExampleSelective(t, example);

	}

	@Override
	public void delete(CoreArchiveTopic t) {
		CoreArchiveTopicCriteria example = new CoreArchiveTopicCriteria();
		example.createCriteria().andTopicidEqualTo(t.getTopicid());
		arachiveTopic.deleteByExample(example);

	}

}
